package com.hustbaidu.hustmapplacepro2;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class Lecture extends Activity {
	private ListView listView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lecture);
		
		listView = (ListView)findViewById(R.id.lecturelist);
		
		SimpleAdapter adapter = new SimpleAdapter(this, getData(), R.layout.lectureintro, 
				new String[]{"lecture_name","person","place","time","type"}, 
				new int[]{R.id.lecture_name,R.id.person,R.id.place,R.id.time,R.id.type});
		listView.setAdapter(adapter);
		
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				Map<String, Object> map = (Map<String, Object>)listView.getItemAtPosition(arg2);
				Intent intent = new Intent();
				Bundle bundle = new Bundle();
				bundle.putString("place", (String)map.get("place"));
				bundle.putString("lecture_name", (String)map.get("lecture_name"));
				bundle.putString("person", (String)map.get("person"));
				bundle.putString("time", (String)map.get("time"));
				bundle.putString("type", (String)map.get("type"));
				intent.putExtras(bundle);
				intent.setClass(Lecture.this, LectureDetailActivity.class);				
				startActivity(intent);
				
				
				
			}
			
		});
	}
	
	private List<Map<String, Object>> getData(){
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		Map<String, Object> map = null;
		
		
			map = new HashMap<String, Object>();
			map.put("lecture_name", "创新时代，急速生活，设计体验");
			map.put("person", "<美>Mary Peter");
			map.put("place", "东九D302");
			map.put("time", "9.21 14:30—17:00");
			map.put("type", "人文社科");
			list.add(map);
			map = new HashMap<String, Object>();
			map.put("lecture_name", "创新人才");
			map.put("person", "Mary Peter");
			map.put("place", "东九D302");
			map.put("time", "9.21 14:30—17:00");
			map.put("type", "自然科学");
			list.add(map);
			map = new HashMap<String, Object>();
			map.put("lecture_name", "东九楼简史");
			map.put("person", "Mary Peter");
			map.put("place", "东十二1302");
			map.put("time", "9.21 14:30—17:00");
			map.put("type", "宣讲会");
			list.add(map);
			map = new HashMap<String, Object>();
			map.put("lecture_name", "东九楼简史");
			map.put("person", "Mary Peter");
			map.put("place", "东十二1302");
			map.put("time", "9.21 14:30—17:00");
			map.put("type", "人文");
			list.add(map);
			map = new HashMap<String, Object>();
			map.put("lecture_name", "东九楼简史");
			map.put("person", "Mary Peter");
			map.put("place", "东十二1302");
			map.put("time", "9.21 14:30—17:00");
			map.put("type", "人文");
			list.add(map);
			map = new HashMap<String, Object>();
			map.put("lecture_name", "东九楼简史");
			map.put("person", "Mary Peter");
			map.put("place", "东十二1302");
			map.put("time", "9.21 14:30—17:00");
			map.put("type", "人文");
			list.add(map);
		
		return list;
	}
	
	

}
